package com.junlaninfo;

/**
 * Created by 辉 on 2020/12/28.
 */
public class test1 {
    public static void main(String[] args) {
        int[] arr = {5, 9, 1, 10, 8};
//        外层for控制循环的次数
        for (int i=0;i<arr.length-1;i++){
//            内层for用于比较循环比较的个数
            for(int j=i+1;j<arr.length;j++){
                if (arr[i] > arr[j]){
                    int temp = arr[i];
                    arr[i] = arr[j];
                    arr[j] = temp;
                }
            }

        }
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        for (int i = 0; i <= arr.length-1; i++) {
            if (i == arr.length - 1) {
                buffer.append(arr[arr.length-1] + "]");
            } else {
                buffer.append(arr[i]+",")
                ;
            }
        }
        System.out.println(buffer);
    }
}
